package com.ruoyi.demo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.demo.domain.SakuraExp;
import com.ruoyi.demo.service.ISakuraExpService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 就业经验Controller
 * 
 * @author 蓝鲸
 * @date 2024-08-09
 */
@RestController
@RequestMapping("/demo/exp")
public class SakuraExpController extends BaseController
{
    @Autowired
    private ISakuraExpService sakuraExpService;

    /**
     * 查询就业经验列表
     */
    @PreAuthorize("@ss.hasPermi('demo:exp:list')")
    @GetMapping("/list")
    public TableDataInfo list(SakuraExp sakuraExp)
    {
        startPage();
        List<SakuraExp> list = sakuraExpService.selectSakuraExpList(sakuraExp);
        return getDataTable(list);
    }

    /**
     * 导出就业经验列表
     */
    @PreAuthorize("@ss.hasPermi('demo:exp:export')")
    @Log(title = "就业经验", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SakuraExp sakuraExp)
    {
        List<SakuraExp> list = sakuraExpService.selectSakuraExpList(sakuraExp);
        ExcelUtil<SakuraExp> util = new ExcelUtil<SakuraExp>(SakuraExp.class);
        util.exportExcel(response, list, "就业经验数据");
    }

    /**
     * 获取就业经验详细信息
     */
    @PreAuthorize("@ss.hasPermi('demo:exp:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sakuraExpService.selectSakuraExpById(id));
    }

    /**
     * 新增就业经验
     */
    @PreAuthorize("@ss.hasPermi('demo:exp:add')")
    @Log(title = "就业经验", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SakuraExp sakuraExp)
    {
        return toAjax(sakuraExpService.insertSakuraExp(sakuraExp));
    }

    /**
     * 修改就业经验
     */
    @PreAuthorize("@ss.hasPermi('demo:exp:edit')")
    @Log(title = "就业经验", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SakuraExp sakuraExp)
    {
        return toAjax(sakuraExpService.updateSakuraExp(sakuraExp));
    }

    /**
     * 删除就业经验
     */
    @PreAuthorize("@ss.hasPermi('demo:exp:remove')")
    @Log(title = "就业经验", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sakuraExpService.deleteSakuraExpByIds(ids));
    }
}
